/**
 * 
 */
package com.feib.stms.batch.dao.rowmapper;

import java.sql.ResultSet;


import org.springframework.jdbc.core.RowMapper;


import com.feib.stms.batch.domain.Group;
import com.feib.stms.batch.domain.UploadFile;
import com.feib.stms.batch.domain.User;

/**
 * @author Jeff Gu
 *
 */
public class UploadFileRowMapper extends BaseRowMapper<UploadFile> implements RowMapper<UploadFile>{

	private static final long serialVersionUID = 8204132357999334582L;	
	
	public UploadFileRowMapper() {
		super(UploadFile.class);
		
	}

	@Override
	protected UploadFile doOtherMapRow(ResultSet rs, int rowNumber,UploadFile entity )
	{		
		entity.setFileMd5((String)getColumnValue(rs, "FILE_MD5", String.class));
	
		User user = new User();
		entity.setUploadUser(user);//上傳人員 UPLOAD_USER_PK
		/* 塞上傳人員的關聯 */
		user.setUserPk((Long)getColumnValue(rs, "USER_PK", Long.class));
		user.setUserId((String)getColumnValue(rs, "USER_ID", String.class));
		user.setUserName((String)getColumnValue(rs, "USER_NAME", String.class));	
		user.setGroup(new Group());
		user.getGroup().setGroupNo((String)getColumnValue(rs, "GROUP_NO", String.class));
		user.getGroup().setGroupPk((Long)getColumnValue(rs, "GROUP_PK", Long.class));
		user.getGroup().setGroupName((String)getColumnValue(rs, "GROUP_NAME", String.class));
		entity.setGroup(user.getGroup());
		
		
		User userLog = new User();
		userLog.setUserPk((Long)getColumnValue(rs, "USER_PK", Long.class));
		userLog.setUserId((String)getColumnValue(rs, "USER_ID", String.class));
		userLog.setUserName((String)getColumnValue(rs, "USER_NAME", String.class));	
	
		/* 應該非物件類不用設關聯 */
		/* ex:entity.setFileFormat((String)getColumnValue(rs, "FILE_FORMAT ", String.class));//檔案格式*/
	
		return entity;
		
	}
	
	
	
	

}
